/*
*
*
*     文档创建：jjl, jjl@hzncc.com
*/

package definitions;
    parameter VERSION = "1.1";
    typedef enum {ADD, SUB, MUL} opcodes_t;

    typedef struct packed{
        logic [31:0] a, b;
        opcodes_t   opcode;
    } instruction_t;

    function automatic [31:0] multiplier (input [31:0] a, b);
        return a * b;
    endfunction
endpackage


module test(
            input   definitions::instruction_t  IW              ,
            input   logic                       sys_clk         ,
            output  logic   [31:0]              result
        );


    always_ff@(posedge sys_clk)
        case(IW.opcode)
            definitions::ADD : result = IW.a + IW.b;
            definitions::SUB : result = IW.a - IW.b;
            definitions::MUL : result = definitions::multiplier(IW.a, IW.b);
        endcase
endmodule
